﻿using Microsoft.Xna.Framework;
using SomeGame.GUI.Widgets;
using SomeGame.GUI.Widgets.BlockWidgets;
using SomeGame.GUI.Widgets.Containers;
using SomeGame.GUI.Widgets.Events.Click;
using SomeGame.GUI.Widgets.InlineWidgets;

namespace SomeGame.GUI.Screens {

    public class PausedScreen : Screen, IClickSubscriber {

        public PausedScreen() {
            Name = ScreenManager.PAUSED_SCREEN;
            RootContainer = new RootContainer(this, GameEngine.Blank, GameEngine.GameBounds, new Color(20, 20, 20, 20));

            // Screen Label
            Label screenLabel = new Label(GameEngine.Blank,
                200,
                60,
                Color.Transparent,
                GameEngine.Consolas16,
                Color.DarkOliveGreen,
                "Game Paused") {
                    ID = "PausedScreen_PausedScreenLabel",
                    Margin = new Margin(100, 0, 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Center
                };
            RootContainer.AddWidget(screenLabel);

            // BR due to two inline, centered widgets being back to back.
            RootContainer.AddWidget(new Break());

            // Button Container.
            InlineContainer widgetContainer = new InlineContainer(GameEngine.Blank, new Color(10, 10, 10)) {
                ID = "PausedScreen_PausedScreenButtonContainer",
                Margin = new Margin(50, 0, 0, 0),
                Padding = new Padding(10),
                HorizontalAlignment = HorizontalAlignment.Center
            };
            RootContainer.AddWidget(widgetContainer);

            // Continue.
            Button continueButton = new Button(GameEngine.Blank,
                200,
                50,
                new Color(150, 90, 50),
                GameEngine.Consolas16,
                Color.AntiqueWhite,
                "Continue") {
                    ID = "PausedScreen_ContinueButton",
                    HoverColor = new Color(170, 130, 80)
                };
            continueButton.AddSubscriber(this);
            widgetContainer.AddWidget(continueButton);
            widgetContainer.AddWidget(new Break());

            // Quit.
            Button quitButton = new Button(GameEngine.Blank,
                200,
                50,
                new Color(150, 90, 50),
                GameEngine.Consolas16,
                Color.AntiqueWhite,
                "Quit") {
                    Margin = new Margin(10, 0, 0, 0),
                    ID = "PausedScreen_QuitButton",
                    HoverColor = new Color(170, 130, 80)
                };
            quitButton.AddSubscriber(this);
            widgetContainer.AddWidget(quitButton);

            RootContainer.Layout();
        }

        public void OnClick(ClickEventArgs clickEventArgs) {
            switch (((Widget) clickEventArgs.ClickPublisher).ID) {
                case "PausedScreen_ContinueButton":
                    ScreenManager.DeactivateScreen(Name);
                    GameEngine.IsPaused = false;
                    break;
                case "PausedScreen_QuitButton":
                    ScreenManager.ActivateScreen(ScreenManager.ARE_YOU_SURE_SCREEN);
                    break;
            }
        }

    }

}